import static org.junit.Assert.*;
import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

// This unit test initializes an instance of a linked list, populates the list with nodes,
// then uses the delete() method to remove the added nodes.  The assert method is used
// to check the number of remaining nodes at the end of the procedure.

public class TestDelete {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@SuppressWarnings("deprecation")
	@Test
	public void testDelete() {
		
		//initialize linked list and insert nodes
		
		LinkedList ll = new LinkedList();
		int nodeData = 0;
		int numberOfNodes = 1;
		int numberOfElementsInList = 2;
	
		while(numberOfElementsInList != 0)
		{
			ll.insert(nodeData);
			nodeData = nodeData + 1;
			numberOfNodes = numberOfNodes + 1;
			numberOfElementsInList = numberOfElementsInList - 1;
		}
		
		//delete inserted nodes
		
		Node node = ll.getNodeForList();
		while(nodeData >= 0)
		{
			ll.delete(nodeData);
			nodeData = nodeData - 1;
			numberOfNodes = numberOfNodes - 1;
		}	
		
	//check for number of remaining nodes
	assertEquals(0, numberOfNodes);
	//check for value of start node
	assertEquals(0,node.getData());
	
	}
}
